//用户输入整数n，计算1!+(1!+2!)+(1!+2!+3!)+…..+(1!+2!+…n!)
//      用方法实现
//    有参数有返回值

import java.util.Scanner;

public class 求阶乘之和 {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n, sum = 0, s = 1;
        do {
            System.out.println("请输入一个整数:");
            n = sc.nextInt();
        }
        while (n <= 0);

        for (int i = n; i > 1; i--) {
            s = s * i;
            sum = sum + s;
        }
        System.out.println(sum);
    }
}
